<template>
    <div class="newinfo-container">
        <div class="title">
            <h1>{{ newsinfo.title }}</h1>
            <p>
                <span>发表时间：{{ newsinfo.create_time | DateFormat }}</span><span>点击次数：{{ newsinfo.click }}</span>
            </p>
        </div>
        <hr>
        <div class="content" v-html="newsinfo.content">
        </div>

        <comment :id="id"></comment>
    </div>
</template>

<script>
// 导入评论子组件
import comment from "../comment/comment.vue"

export default {
    data() {
        return {
            id: this.$route.params.id,
            newsinfo:{}
        }
    },
    created() {
        this.getById()
    },
    methods: {
        getById(){
            this.$http.get("news/get/"+this.id).then(result => {
                if (result.data.code === 0) {
                    this.newsinfo = result.data.data
                } else {
                    Toast("获取新闻详情失败！")
                }

            }, err  => {
                Toast("获取新闻详情失败！")
            })
        }
    },
    components: {
        comment
    }
}
</script>

<style lang="less" scoped>
.newinfo-container{
    padding: 0 5px;
    .title h1{
        font-size: 16px;
        color: red;
        text-align: center;
        margin: 15px 0;
    }

     .title p{
        display: flex;
        justify-content: space-between;
        color: #226aff;
     }

}
</style>